import axios from 'axios'

export default {
  namespaced: true,
  state: {
    token: '',
    userinfo: {}
  },
  mutations: {
    updateToken (state, token) {
      state.token = token
    },
    updateUserInfo (state, userinfo) {
      state.userinfo = userinfo
    }
  },
  actions: {
    async getUserInfo (context) {
      const { data: res } = await axios.get('/my/userinfo')
      context.commit('updateUserInfo', res.data)
    }
  },
  getters: {
  }
}
